package com.pickgliss.loader
{
	import com.pickgliss.ui.ComponentSetting;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLVariables;

	public class BitmapLoader extends DisplayLoader
	{
		private static const InvalidateBitmapDataID:int = 2015;
		
		public function BitmapLoader(id:int,url:String)
		{
			super(id,url);
		}

		private var _sourceBitmap:Bitmap;
		
		override public function get content():*
		{
			if(_sourceBitmap == null)return null;
			return _sourceBitmap;
		}
		
		public function get bitmapData():BitmapData
		{
			if(!_sourceBitmap)return null;
			return _sourceBitmap.bitmapData;
		}
		
		override protected function __onDataLoadComplete(event:Event):void
		{
			if(_url.indexOf("mapmaterial/floor/plant/shuzhi01.png") >= 0)
			{
				trace();
			}
			var md5:String = ComponentSetting.getUrlMd5(_url);
			LoaderSavingManager.cacheFile(_url,_loader.data,false,md5);
			super.__onDataLoadComplete(event);
		}
		
		override protected function __onContentLoadComplete(event:Event):void
		{
			_sourceBitmap = _displayLoader.content as Bitmap;
			super.__onContentLoadComplete(event);
		}
		
		override public function get type():int
		{
			return BaseLoader.BITMAP_LOADER;
		}
	}
}